package com.dl7.mvp.music.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.dl7.mvp.video.bean.RcmdVideoAlbumList;
import com.dl7.mvp.video.bean.VideoAlbumList;

public class MusicInfo implements Parcelable {
    private int albumId;
    private int count;
    private String name;
    private String image;
    private String desc;
    private String duration;
    private String url;

    // ===================
    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeInt(albumId);
        parcel.writeInt(count);
        parcel.writeString(name);
        parcel.writeString(image);
        parcel.writeString(desc);
        parcel.writeString(duration);
        parcel.writeString(url);
    }

    protected MusicInfo(Parcel in) {
        albumId = in.readInt();
        count = in.readInt();
        name = in.readString();
        image = in.readString();
        desc = in.readString();
        duration = in.readString();
        url = in.readString();
    }

    public static final Creator<MusicInfo> CREATOR = new Creator<MusicInfo>() {
        @Override
        public MusicInfo createFromParcel(Parcel in) {
            return new MusicInfo(in);
        }

        @Override
        public MusicInfo[] newArray(int size) {
            return new MusicInfo[size];
        }
    };

    // ===================

    /**
     * @param albumBean 音乐专辑列表里的专辑信息
     */
    public MusicInfo(MusicAlbumList.DataBean albumBean) {
        albumId = albumBean.getId();
        name = albumBean.getName();
        image = albumBean.getImage();
        count = albumBean.getCount();
        desc = albumBean.getDescription();
    }

    /**
     * 通过专辑详情构建
     *
     * @param audioBean
     */
    public MusicInfo(MusicBean.RecordBean.AudiosBean audioBean) {
        albumId = audioBean.getId();
        name = audioBean.getName();
        image = audioBean.getImage();
        count = audioBean.getPlayCount();
        int time = (int)audioBean.getDuration();
        duration = time / 60 + "分" + time % 60 + "秒";
        url = audioBean.getResource();
    }

    public int getAlbumId() {
        return albumId;
    }

    public void setAlbumId(int albumId) {
        this.albumId = albumId;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public String getDuration() {
        return duration;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = name;
    }
}
